package com.ykzb.project.model;

import java.io.Serializable;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.apache.commons.lang3.StringUtils;

import com.ykzb.enums.QiniuBucket;
import com.fasterxml.jackson.annotation.JsonIgnore;

public class ProjectOwnerInfo  implements Serializable {

	private long ownerId;

	private String nickname;

	private String mobile;

	private int sex;

	private int registerType;

	@JsonIgnore
	private String avatarKey;

	@JsonIgnore
	private String avatarKeyVersion;

	public String getHeadImgUrl() {
		if (StringUtils.isNotBlank(avatarKey)) {
			Pattern p = Pattern.compile("^http://.*|^https://.*");
			Matcher m = p.matcher(avatarKey);
			if (m.matches()) {
				return avatarKey;
			}

			return QiniuBucket.HEAD_IMG.getDomain() + avatarKey + "?v=" + avatarKeyVersion;
		}

		return "";
	}

	public long getOwnerId() {
		return ownerId;
	}

	public void setOwnerId(long ownerId) {
		this.ownerId = ownerId;
	}

	public String getNickname() {
		return nickname;
	}

	public void setNickname(String nickname) {
		this.nickname = nickname;
	}

	public String getMobile() {
		return mobile;
	}

	public void setMobile(String mobile) {
		this.mobile = mobile;
	}

	public int getSex() {
		return sex;
	}

	public void setSex(int sex) {
		this.sex = sex;
	}

	public int getRegisterType() {
		return registerType;
	}

	public void setRegisterType(int registerType) {
		this.registerType = registerType;
	}

	public String getAvatarKey() {
		return avatarKey;
	}

	public void setAvatarKey(String avatarKey) {
		this.avatarKey = avatarKey;
	}

	public String getAvatarKeyVersion() {
		return avatarKeyVersion;
	}

	public void setAvatarKeyVersion(String avatarKeyVersion) {
		this.avatarKeyVersion = avatarKeyVersion;
	}

}
